import React, { useEffect, useState } from 'react'

import PubSub from 'pubsub-js'


export default function B() {

  let [aComData, setAComData] = useState({})

  // 发布消息
  useEffect(() => {
    function x() {
      PubSub.subscribe('myClick', (_, data) => {
        console.log('B收到消息', _, data)

        setAComData(data)
      })
    }

    x()
  }, [])
  return (
    <div>
      B<br />
      A组件 aa: {aComData.aa}
      <br />
      A组件 bb: {aComData.bb}

    </div>
  )
}
